<%@ page import="java.io.*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
        <%= request.getParameter("name") %>
        <%= request.getParameter("email") %>
        <%= request.getParameter("contant") %>
        
<%

    
    String name = request.getParameter("name");
    String email = request.getParameter("email");
    String contant = request.getParameter("contant");
    String result;
    // Recipient's email ID needs to be mentioned.
    String to = email;

    // Sender's email ID needs to be mentioned
    String from = "kwokhho3@student.cityu.edu.hk";

    // Assuming you are sending email from localhost
    String host = "stdsmtp.cityu.edu.hk";

    // Get system properties object
    Properties properties = System.getProperties();

    // Setup mail server
    properties.setProperty("mail.smtp.host", host);

    // Get the default Session object.
    Session mailSession = Session.getDefaultInstance(properties);

    try {
        // Create a default MimeMessage object.
        MimeMessage message = new MimeMessage(mailSession);
        // Set From: header field of the header.
        message.setFrom(new InternetAddress(from));
        // Set To: header field of the header.
        message.addRecipient(Message.RecipientType.TO,
                new InternetAddress(to));
        // Set Subject: header field
        message.setSubject("Football Manager");
        // Now set the actual message
        message.setText(contant);
        // Send message
        Transport.send(message);
        result = "Sent message successfully....";
    } catch (MessagingException mex) {
        mex.printStackTrace();
        result = "Error: unable to send message....";
    }
%>
<html>
    <head>
        <title>Send Email</title>
    </head>
    <body>
    <center>
        <h1>Send Email</h1>
    </center>
    <p align="center">
        <%
            out.println("Result: " + result + "\n");
        %>
    </p>
</body>
</html>